<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .warpper {
        width: 400px;
        height: 400px;
        background-color: #aca;
        position: relative;
      }

      .center-box {
        position: absolute;
        top: 100px;
        left: 100px;
        width: 200px;
        height: 200px;
        background-color: #ffa;
      }
    </style>
  </head>
  <body>
    <div class="warpper">
      <div class="center-box" title="垂直居中"></div>
    </div>
    <script>
      window.location.href + '#123'

      var obj = {
        a: {
          b: {
            c: {
              d: 1
            }
          }
        }
      }

      function getValue(obj, path) {
        console.log(obj, path)

        if (path.indexOf('.') !== -1) {
          var names = path.split('.')
          var tmp = obj
          for (let i = 0; i < names.length; i++) {
            tmp = tmp?.[names[i]]
          }
        }
        return tmp
      }
      console.log(getValue(obj, 'a.b.c.d'))
      console.log(getValue(obj, 'a.b'))
    </script>
  </body>
</html>
